package leetcode_core.leetcode_1;

public class RemoveDuplicates {
    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if(n==0){
            return 0;
        }
        int slow = 0 ,fast = 1;
        while(fast <n ){
            if(nums[fast] != nums[slow]){
                slow++;
                //维护nums[0...slow]不重复
                nums[slow] = nums[fast];
            }
            fast++;
        }
        return slow+1;
    }
}
